package org.example.sportdemo.service;

import org.example.sportdemo.entity.Carousel;
import org.example.sportdemo.entity.Competition;
import org.example.sportdemo.mapper.CarouselMapper;
import org.example.sportdemo.mapper.CompetitionMapper;
import org.example.sportdemo.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;

    public List<Carousel> selectAll(){
        return carouselMapper.selectAll();
    }

    public PageUtils queryPage(Map<String, Object> params) {
        //总数据
        List<Carousel> carouselList = carouselMapper.selectAll();
        //总条数
        Integer totalCount = carouselMapper.selectCount();
        //当前页
        Integer currPage = Integer.valueOf((String) params.get("currPage"));
        //每页条数
        Integer pageSize = Integer.valueOf((String) params.get("pageSize"));
        return new PageUtils(totalCount,(Integer) pageSize,currPage,carouselList);
    }

    public void addCarousel(Carousel carousel) {

        carouselMapper.addCarousel(carousel);

    }

    public Carousel selectById(Integer id) {
        return carouselMapper.selectById(id);
    }

    public void updateCarousel(Carousel Carousel) {
        carouselMapper.updateCarousel(Carousel);
    }

    public void deleteByIds(Integer[] ids) {
        carouselMapper.deleteByIds(ids);
    }
}
